Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

glsl-token-inject-block

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glsl-token-inject-block

safely inject a block of tokens into a shader

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
178K
decreased by-28.71%
Maintainers
1
Weekly downloads
 
Created
Source

glsl-token-inject-block

unstable

Injects a "block" of GLSL tokens into a shader, after any #version, #extension and precision statements. This will pad the new tokens with the necessary amount of newlines (but no more).

This module ignores token line, column and position.

Example

Your source:

var tokenizer = require('glsl-tokenizer')
var inject = require('glsl-token-inject-block')
var stringify = require('glsl-token-string')

var tokens = tokenizer(shaderInput)
var newToken = { 
  type: 'preprocessor', 
  data: '#define FOOBAR' 
}

var source = stringify(inject(tokens, newToken))
console.log(source)

The following shader input:

// some comment
#version 300 es
#extension SOME_EXTENSION : enable

void main() {}

Results in the following injected define:

// some comment
#version 300 es
#extension SOME_EXTENSION : enable
#define FOOBAR

void main() {}

Usage

NPM

tokens = inject(tokens, newTokens)

For the given shader source (tokens), injects newTokens into them, assuming the new tokens are a "block" of code that should be placed on its own line.

newTokens can be a single token object, or an array of token objects.

Modifies tokens in place and returns it.

License

MIT, see LICENSE.md for details.

Keywords

FAQs

Package last updated on 11 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc